import {
  AppStateInterface,
  AppActionTypes,
  UPDATE_WEB_NAV_INDEX,
  UPDATE_TEST_DATA,
} from './types'

const initialState: AppStateInterface = {
  webNavIndex: '',
  testNum: 0
}

export function appReducer(
  state = initialState,
  action: AppActionTypes
): AppStateInterface {
  switch (action.type) {
    case UPDATE_WEB_NAV_INDEX: {
      return {
        ...state,
        webNavIndex: action.value
      }
    }
    case UPDATE_TEST_DATA: {
      return {
        ...state,
        testNum: action.value
      }
    }
    default:
      return state
  }
}